﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace EssenceAnalytics.Data.EntityModel
{
    /// <summary>
    /// Newsletter
    /// </summary>
    [Bind(Include = "SessionId,Name,Email,IsActive,CreatedDate")]
    [MetadataType(typeof (NewsletterMetaData))]
    public partial class Newsletter
    {
        /// <summary>
        /// Newsletter Meta Data for Validation
        /// </summary>
        [Bind(Exclude = "NewsletterId")]
        public class NewsletterMetaData
        {
            /// <summary>
            /// NewsletterId
            /// </summary>
            [ScaffoldColumn(false)]
            public object NewsletterId { get; set; }

            /// <summary>
            /// Newsletter Session
            /// </summary>
            public string SessionId { get; set; }

            /// <summary>
            /// Name
            /// </summary>
            [Required(ErrorMessage = "Name is required")]
            [StringLength(160)]
            public string Name { get; set; }

            /// <summary>
            /// Email
            /// </summary>
            [Required(ErrorMessage = "Email Required!")]
            [RegularExpression(
                "^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\\-+)|([A-Za-z0-9]+\\.+)|([A-Za-z0-9]+\\++))*[A-Za-z0-9]+@((\\w+\\-+)|(\\w+\\.))*\\w{1,63}\\.[a-zA-Z]{2,6}$"
                , ErrorMessage = "Not a valid email!")]
            public string Email { get; set; }

            /// <summary>
            /// Status of the Notification
            /// </summary>
            public bool IsActive { get; set; }

            /// <summary>
            /// Creation Date
            /// </summary>
            public DateTime CreatedDate { get; set; }
        }
    }
}